Shader "Custom/NewSurfaceShader"
{
    Properties
    {
        _Color ("Color", Color) = (1,1,1,1)
        _MainTex ("Albedo (RGB)", 2D) = "white" {}
        _Glossiness ("Smoothness", Range(0,1)) = 0.5
        _Metallic ("Metallic", Range(0,1)) = 0.0
        _modNum ("条纹数量", Range(2,30)) = 10.0
        _uRatio ("占比", Range(0,1)) = 0.3

    }
    SubShader
    {
        Tags { "RenderType"="transparent"}
        LOD 200

        CGPROGRAM
        // Physically based Standard lighting model, and enable shadows on all light types
        #pragma surface surf Standard fullforwardshadows

        // Use shader model 3.0 target, to get nicer looking lighting
        #pragma target 3.0

        sampler2D _MainTex;

        struct Input
        {
            float2 uv_MainTex;
        };

        half _Glossiness;
        half _Metallic;
        half _modNum;
        half _uRatio;
        fixed4 _Color;

        // Add instancing support for this shader. You need to check 'Enable Instancing' on materials that use the shader.
        // See https://docs.unity3d.com/Manual/GPUInstancing.html for more information about instancing.
        // #pragma instancing_options assumeuniformscaling
        UNITY_INSTANCING_BUFFER_START(Props)
            // put more per-instance properties here
        UNITY_INSTANCING_BUFFER_END(Props)

        // floor,ceil和 frac
        void surf (Input IN, inout SurfaceOutputStandard o)
        {
       
 // https://learn.u3d.cn/tutorial/mathematical-visualization-art?chapterId=63f44580fe40ab001f923ced#63f44a029e22c9001fb093a4
  float scale =5.0;
   
 IN.uv_MainTex = (IN.uv_MainTex*2.0-1.0) *scale;
//  坐标轴
   float axis =  smoothstep(0.01,0.0,abs(IN.uv_MainTex.y/scale))
    +smoothstep(0.01,0.0,abs(IN.uv_MainTex.x/scale)); //x=0的函数和y=0的函数，uv到-5到+5之间
// 极坐标系
float r = length(IN.uv_MainTex);
float angle = atan2(IN.uv_MainTex.y,IN.uv_MainTex.x);
float a = -1 ,b=1,k=1;
// 函数
// float f =  b+ a*cos(k*angle);
// 心形函数
float f =  2-2*sin(angle)+sin(angle)*sqrt(abs(cos(angle)))/(sin(angle)+1.4);
float plot = 1.0-step(f,r);
    o.Albedo = axis*_Color + plot ;
    o.Alpha = 1.0;
        }
        ENDCG
    }
    FallBack "Diffuse"
}
